//
//  main.m
//  NSDictionary预习
//
//  Created by dllo on 16/7/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1",@"key1",@"value2",@"key2",@"value3",@"key3", nil];
        NSDictionary *dic1 = [NSDictionary dictionary];
        NSDictionary *dic2 = [NSDictionary dictionaryWithDictionary:dic];
        NSLog(@"key3 value :%@",[dic objectForKey:@"key3"]);
        NSLog(@"dic count :%ld",dic.count);
        NSArray *keyArr = [dic allKeys];
        NSLog(@"keys :%@",keyArr);
        NSArray *valueArr = [dic allValues];
        NSLog(@"values :%@",valueArr);
        NSMutableDictionary *mutableDic = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"mValue1",@"mKey1",@"mValue2",@"mKey2",@"mValue3",@"mKey3", nil];
        //添加字典数据
        [mutableDic addEntriesFromDictionary:dic];
        NSLog(@"mutableDictionary%@",mutableDic);
        //添加字典键值对
        [mutableDic setValue:@"success" forKey:@"study"];
        //改变原始字典,以旧换新
        [mutableDic setDictionary:dic];
         NSLog(@"set dictionary%@",mutableDic);
//        [mutableDic removeAllObjects];
//        [mutableDic removeObjectForKey:@"key1"];
        //快速遍历
        for (id key in mutableDic) {
            NSLog(@"key :%@ value :%@",key,[mutableDic objectForKey:key]);
        }
        //枚举遍历
        NSEnumerator *enumerator = [mutableDic keyEnumerator];
        id key = [enumerator nextObject];
        while (key) {
            NSLog(@"enumerator :%@",[mutableDic objectForKey:key]);
            key = [enumerator nextObject];
        }
    }
    return 0;
}
